package org.ypx.center.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.ypx.center.service.IUserRoleService;
import org.ypx.db.entity.UserRole;

import java.util.List;

/**
 * @author Yan Peixuan
 * @date 2017/3/28 20:45
 * @description
 */
@Service
public class UserRoleServiceImpl extends BaseServiceImpl<UserRole> implements IUserRoleService {

    @Override
    public void correlationRoles(Long userId, Long... roleIds) {
        UserRole userRole = new UserRole();
        userRole.setUserId(userId);
        this.delete(userRole);
        for (Long roleId : roleIds) {
            userRole.setRoleId(roleId);
            super.save(userRole);
        }
    }
}
